package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.MyNotice;
import com.czh.springboot04.mapper.MyNoticeMapper;
import com.czh.springboot04.service.MyNoticeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyNoticeServiceImpl implements MyNoticeService {
    @Autowired
    private MyNoticeMapper myNoticeMapper;
    @Override
    public int mynoticeAdd(MyNotice myNotice) {
        int i = myNoticeMapper.mynoticeAdd(myNotice);
        return  i;
    }

    @Override
    public int mynoticeUpdate(MyNotice myNotice) {
        int i = myNoticeMapper.mynoticeUpdate(myNotice);
        return i;
    }

    @Override
    public int mynoticeDelete(int id) {
        int i = myNoticeMapper.mynoticeDelete(id);
        return i;
    }

    @Override
    public PageInfo<MyNotice> mynoticeSelectAll(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MyNotice> list = myNoticeMapper.mynoticeSelectAll();
        PageInfo<MyNotice> pageInfo = new PageInfo<>(list);
        return pageInfo;


    }

    @Override
    public PageInfo<MyNotice> mynoticeSelectByMore(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MyNotice> list = myNoticeMapper.mynoticeSelectByMore();
        PageInfo<MyNotice> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<MyNotice> mynoticeSelectByName(int pageNum, int pageSize, String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<MyNotice> list = myNoticeMapper.mynoticeSelectByName(name);
        PageInfo<MyNotice> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
